<template>
	<view class="content">
		
		<view class="title fs18 C333">投诉详情</view>
		<view class="process">
			<view class="flexsb processTitle">				                  																					   
				 <view style="margin-left: -40upx;"  class="processActive">填写投诉内容</view>
				 <view style="margin-left: -25upx;"  class="">平台审核</view>
				 <view  class="">投诉完成</view>				
			</view>

			<view style="position: relative;z-index: 0;top: 40upx;width: 520upx;height: 2upx;margin: 0 auto;" class="progress-box">
				<progress activeColor="#ff4300" percent="0" stroke-width="2" />
			</view>
			
			<view  class="flexsb circles">
				<view class="">
					<image v-if="true" style="width: 40upx;height: 40upx;" src="/static/images/login/xuanzhong-icon.png" mode=""></image>
					<image v-if="false" style="width: 40upx;height: 40upx;" src="@/static/images/new_tousugg2.jpg" mode=""></image>
				</view>
				<view class="">
					<image v-if="false" style="width: 40upx;height: 40upx;" src="/static/images/login/xuanzhong-icon.png" mode=""></image>
					<image v-if="true" style="width: 40upx;height: 40upx;" src="@/static/images/new_tousugg2.jpg" mode=""></image>
				</view>
				<view class="">
					<image v-if="false" style="width: 40upx;height: 40upx;" src="/static/images/login/xuanzhong-icon.png" mode=""></image>
					<image v-if="true" style="width: 40upx;height: 40upx;" src="@/static/images/new_tousugg2.jpg" mode=""></image>
				</view>
			</view>
		
			
		</view>
		
		
		<view class="tousuContent">
			<view class="title2 fs18 C333">投诉信息</view>
			
			<view class="flex0 commonLi">
				<view style="width: 160upx;" class="fs18 C333">被投诉商家:</view>
				<view class="fs18 Cf71c6e">{{store_name}}</view>				
			</view>
			<view class="flex0 commonLi">
				<view style="width: 160upx;" class="fs18 C333">相关商品：</view>
				<view class="fs18 C999">
					<image style="width:85upx;height: 85upx;" :src="goods_image" mode=""></image>
					<view style="width: 530upx;color: #333333; " class="twoline">{{goods_name}}</view>				
				</view>				
			</view>
			<view class="flex0 commonLi">
				<view style="width: 160upx;" class="fs18 C333">投诉主题：</view>
				<view class="fs18 C999">
					<view class="uni-list-cell-db" style="width:500rpx;background: #F6F6F6;border-radius: 12rpx;padding: 10rpx 20rpx;color: #333333;">
						<picker @change="bindPickerChange" :value="index" :range="array">
							<label>{{array[index]}}</label>
						</picker>
					</view>
				</view>				
			</view>
			
			<view class="flex0 commonLi">
				<view style="width: 160upx;" class="fs18 C333">投诉内容：</view>
				<view class="fs18 C999">
					<textarea v-model="jbText"  style="width:520rpx;background: #F6F6F6;padding: 20upx;box-sizing: border-box;color: black;font-size: 30rpx;" value="" />
				</view>				
			</view>
			<view class="flex0 commonLi">
				<view style="width: 160upx;" class="fs18 C333">添加图片：</view>
				<view class="fs18 C999">
					<view class="">
						<image style="width: 160upx;height: 160upx;" @click="upload(1)" :src="img1 ? img1 : `${picUrl}/w/pt.png`" mode=""></image>
						<image style="width: 160upx;height: 160upx;" @click="upload(2)" :src="img2 ? img2 : `${picUrl}/w/pt.png`" mode=""></image>
						<image style="width: 160upx;height: 160upx;" @click="upload(3)" :src="img3 ? img3 : `${picUrl}/w/pt.png`" mode=""></image>
						<!-- <image @click="chooseImage"  style="width:194upx;height: 194upx;" :src="addImgUrl" mode=""></image>											 -->
					</view>
					<view class="fs18 C999">
						图片格式（jpg/jpeg/gif/png）
					</view>
				</view>				
			</view>			
			<view @click="submitBtn" class="submitBtn">确认提交</view>
		</view>
		
		
	</view>
	
	
</template>

<script>
	const requImg = require("@/common/api_sign/requImg.js")
	export default {
		data(){
			return{
				img1:"",
				img2:"",
				img3:"",
				isData:true,
				Imgdata:{},
				ImgInfo1:"",
				ImgInfo2:"",
				ImgInfo3:"",
				
				zhuti:"",
				store_name:"",
				goods_name:"",
				goods_image:"",
				order_id:858,
				goods_id:242,
				jbType:0,
				jbTitle:'',
				inform_subject:"",
				jbText:"",
				
				goodsInfo:[],
				type_list:[],
				index:0,
			    array: [],
				current: 0,
				addImgUrl:"/static/images/addImgBtn4.png",
				lis:[],
				id:'',
				active2flag:0,
				// bottomBtn:[
				// 	{"name":"首页","img1":"../../static/images/home_bottom11.png","img2":"../../static/images/home_bottom12.png","toUrl":"../home/index"},
				// 	{"name":"分类","img1":"../../static/images/home_bottom21.png","img2":"../../static/images/home_bottom22.png","toUrl":"../sort/sortPage"},
				// 	{"name":"分销","img1":"../../static/images/home_bottom31.png","img2":"../../static/images/home_bottom32.png","toUrl":"../distribution/list"},
				// 	{"name":"购物车","img1":"../../static/images/home_bottom41.png","img2":"../../static/images/home_bottom42.png","toUrl":"../car/shopCar"},
				// 	{"name":"会员中心","img1":"../../static/images/home_bottom51.png","img2":"../../static/images/home_bottom52.png","toUrl":"/pages/home/Personal_Center"}
				// ]
			}
		},
		onLoad(options) {
			// this.$util.request({
			// 	url: '/mobile/index.php?act=index&op=area_list',
			// 	method: 'post',
			// 	data: {
					
					
			// 	}
			// }).then(res=>{
							
				
			
			// })
			
			
		 this.goods_id=options.goods_id;
		 this.order_id=options.order_id;
			this.getLis();
		},
		onShow() {
			
		},
		methods:{
			upload(i){
				let that = this;
				if(that.isData){
					uni.chooseImage({//图片选择上传
					 count: 1,
					 sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					 sourceType: ['album','camera'], //从相册选择
					 success: (res)=> {
					const tempFilePaths = res.tempFilePaths;
					// console.log('tempFilePaths',tempFilePaths)
					let  data = requImg.request("index.php?act=upload&op=uploadFile&buss_type="+that.$uploadType.uploadtype010);
					 var uper = uni.uploadFile({
					  url:that.$apiurl+"index.php?act=upload&op=uploadFile",
					  filePath:tempFilePaths[0],
					  name: 'file',
					  formData: {
					    "key":data.key,
						buss_type:data.buss_type,
						"api_sign":data.api_sign, 
						"comefrom":data.comefrom,
						"api_time":data.api_time,
					 },
					  success(res1) {
						  let ImgInfo=JSON.parse(res1.data)
						  // console.log('ImgInfo',ImgInfo)
						  that.Imgdata={"filePath":ImgInfo.datas.file_url,"path":ImgInfo.datas.file_name};
						  if(i==1){
							  // console.log('1',that.Imgdata.filePath)
								if(that.Imgdata.filePath){
									that.img1=that.Imgdata.filePath;
									that.ImgInfo1=that.Imgdata.path;
								}else{
									uni.showToast({
										title:"图片上传超时",
										icon:"none"
									})
								}
						  		
						  }else if(i==2){
							  console.log('2',that.Imgdata.filePath)
								if(that.Imgdata.filePath){
									that.img2=that.Imgdata.filePath;
									that.ImgInfo2=that.Imgdata.path;
								}else{
									uni.showToast({
										title:"图片上传超时",
										icon:"none"
									})
								}
						
						  }
						  else if(i==3){
							  console.log('3',that.Imgdata.filePath)
								if(that.Imgdata.filePath){
									that.img3=that.Imgdata.filePath;
									that.ImgInfo3=that.Imgdata.path;
								}else{
									uni.showToast({
										title:"图片上传超时",
										icon:"none"
									})
								}
						  }
					  },
					  })				
					
						// if(i==1){
						// 	uni.showToast({
						// 		title:"图片上传中",
						// 		icon:"loading",
						// 		duration:3000,
						// 		success: () => {													
						// 			setTimeout(()=>{
						// 				if(that.Imgdata.filePath){
						// 					that.img1=that.Imgdata.filePath;
						// 					that.ImgInfo1=that.Imgdata.path;
						// 				}else{
						// 					uni.showToast({
						// 						title:"图片上传超时",
						// 						icon:"none"
						// 					})
						// 				}
						// 			},5000)
						// 		}
						// 	})
							
						// 	// that.img1=tempFilePaths[0];
						// }else if(i==2){
						// 	uni.showToast({
						// 		title:"图片上传中",
						// 		icon:"loading",
						// 		duration:3000,
						// 		success: () => {									
						// 			setTimeout(()=>{
						// 				if(that.Imgdata.filePath){
						// 					that.img2=that.Imgdata.filePath;
						// 					that.ImgInfo2=that.Imgdata.path;
						// 				}else{
						// 					uni.showToast({
						// 						title:"图片上传超时",
						// 						icon:"none"
						// 					})
						// 				}
										
						// 			},5000)
						// 		}
						// 	})
							
						// }
						// else if(i==3){
						// 	uni.showToast({
						// 		title:"图片上传中",
						// 		icon:"loading",
						// 		duration:3000,
						// 		success: () => {									
						// 			setTimeout(()=>{
						// 				if(that.Imgdata.filePath){
						// 					that.img3=that.Imgdata.filePath;
						// 					that.ImgInfo3=that.Imgdata.path;
						// 				}else{
						// 					uni.showToast({
						// 						title:"图片上传超时",
						// 						icon:"none"
						// 					})
						// 				}
										
						// 			},5000)
						// 		}
						// 	})
							
						// 	// that.img2=tempFilePaths[0];
						// }
					 }
					});
				}else{
					uni.showToast({
						title:"图片正在上传中",
						icon:"loading"
					})
				}
				  
			},
			submitBtn(){
				uni.showLoading({})
				this.$util.request({
					url: '/mobile/index.php?act=member_complain&op=complain_save',							      
					method: 'post',
					data: {
						"input_order_id":this.order_id,
						"input_rec_id":this.goods_id,
						"input_complain_subject":this.zhuti||(5+","+this.array[0]),
						"input_complain_content":this.jbText,
						"complain_pic1":this.ImgInfo1,
						"complain_pic2":this.ImgInfo2,
						"complain_pic3":this.ImgInfo3
						
					}
				}).then(res=>{
					if(res.error_code==0){
						uni.showToast({
							title:"提交成功",
							success() {
								setTimeout(()=>{
									uni.redirectTo({
										url:"list"
									})
								},1000)
							}
						})
					}else{
						uni.showToast({
							title:res.message,
							icon:"none"
						})
					}
					
					
				
				}) 
			},
			 bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.index = e.target.value	
				// this.jbTitle=e.target.value
				var complain_subject_id=5-e.target.value
				this.zhuti=complain_subject_id+","+this.array[e.target.value]
			},
			radioIndex(a){
				this.jbType=a
				this.array=this.type_list[a].subject
				this.array=[]
				for(let i=0;i<this.type_list[a].subject.length;i++){
					this.array.push(this.type_list[a].subject[i].inform_subject_content)
				}
			},
			getLis(){
				this.$util.request({
					url: '/mobile/index.php?act=member_complain&op=complain_new',
					method: 'post',
					data: {
						"rec_id":this.goods_id,
						"order_id":this.order_id						
					}
				}).then(res=>{
					if(res.error_code == '3240003'){
						uni.showToast({
							title:res.message,
							icon:"none"
						})
						setTimeout(()=>{
							uni.navigateBack({
								delta:1
							})
						},2000)
					}
					if(res.error_code == '3240002'){
						uni.showToast({
							title:res.message,
							icon:"none"
						})
						setTimeout(()=>{
							uni.navigateBack({
								delta:1
							})
						},2000)
					}
					this.array=[]
					for(let i=0;i<res.datas.subject_list.length;i++){
						this.array.push(res.datas.subject_list[i].complain_subject_content)
					}
					this.goods_image=res.datas.order_info.goods_list[0].goods_image_url
					this.goods_name=res.datas.order_info.goods_list[0].goods_name
					this.store_name=res.datas.order_info.store_name
				})
			},
			tab2(index,url){
				this.active2flag=index
				console.log(this.active2flag);
				uni.switchTab({
					url:url
				})
			},
			chooseImage: async function() {
                uni.chooseImage({
                    sourceType:['camera', 'album'],
                    // #ifdef MP-WEIXIN
                    sizeType: ['compressed', 'original'],
                    // #endif
                    count: 1,
                    success: (res) => {
                        const tempFilePaths = res.tempFilePaths;
						this.addImgUrl=res.tempFilePaths[0]
//                         uni.request({
//                             url: tempFilePaths[0],
//                             method: 'GET',
//                             responseType: 'arraybuffer',
//                             success: ress => {
//                                 let base64 = wx.arrayBufferToBase64(ress.data); //把arraybuffer转成base64 
//                                 base64 = 'data:image/jpeg;base64,' + base64 //不加上这串字符，在页面无法显示的哦
//                                 uni.request({
//                                     url: 'http://localhost/api/v2/file/uploadBase64',
//                                     dataType: 'file',
//                                     method: 'POST',
//                                     header: {
//                                         "Content-Type": "application/x-www-form-urlencoded"
//                                     },
//                                     data: {
//                                         'da': base64
//                                     },
//                                     success: function(uploadFileRes) {
//                                         imglis.push(uploadFileRes.data);
//                                     }
//                                 });
//                             }
//                         })
				
				
                    	}
				})
            }
		}
	}
</script>

<style>
	.titleNview-placing {
		height: var(--status-bar-height);
		box-sizing: content-box;
	 }
	view{
		box-sizing: content-box;		
	}
	uni-page-body {
		background-color: #FFFFFF;
		color: rgb(102, 102, 102);
	}
	.titleNview-placing {
		height: var(--status-bar-height);
		box-sizing: content-box;
	 }
	.lh20{
		line-height: 20upx;
		height: 20upx;
	}
	.lh25{
		line-height: 25upx;
	}
	.lh30{
		line-height: 30upx;
	}
	.lh35{
		line-height: 35upx;
	}
	.lh40{
		line-height: 40upx;
	}
	.lh45{
		line-height: 45upx;
	}
	.lh50{
		line-height: 50upx;
	}
	.lh80{
		line-height: 80upx;
	}
	.C000{
		color: #000000;
	}
	.Ce13d97{
		color: #ff4300;
	}
	.Cfe0000{
		color: #ff4300;
	}
	.Cc06{
		color: #ff4300;
	}
	.mt55mb30{
		margin-top: 55upx;
		margin-bottom: 30upx;
	}
	.Cfff{
		color: #FFFFFF;
	}
	
	.flex{		
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-content: space-between;
	}
	.paddingL20{
		padding-left: 20upx;
	}
	.C999{
		color:#999 ;
	}
	.Cff0101{
		color:#ff0101 ;
	}
	.Cc00251{
		color: #c00251;
	}
	.strick{
		text-decoration: line-through;
	}
	.Cfe0000{
		color: #ff4300;
	}
	.line1{
		width: 430upx;
	}
	.hide{
		display: none;
	}
	.marginB20{
		margin-bottom: 20upx;
	}
	.oneLine{
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.twoline{
	   overflow : hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
	.pl20{
		padding-left: 20upx;
	}
	.positionT{
		position: relative;
		top: 50upx;
	}
	.paddingB15{
		padding-bottom: 15upx;
	}
	.borderB{
		border-bottom: 1px solid #f4f4f6;
	}
	.borderT{
		border-top: 1px solid #f4f4f6;
	}
	.gl{
		position: absolute;
		right: 30upx;
	}
	.pr30{
		padding-right: 30upx;
	}
	.C333{
		color: #333333;
	}
	.C666{
		color: #666666;
	}
	.Cf00{
		color: #ff0000;
	}
	
	.bold{
		font-weight: bold;
	}
	.C1d1d1d{
		color:#1d1d1d ;
	}
	.fl{
		float: left;
	}
	.fr{
		float: right;
	}
	.tac{
		text-align: center;
	}
	.Ce5258e{
		color: #e5258e;
	}
	.Cccc{
		color: #CCCCCC;
	}
	.Cf7881c{
		color: #f7881c;
	}
	uni-page-body {
		background-color: #FFFFFF;
		color: rgb(102, 102, 102);
	}		
	.fs30{
		/* font-size: 30upx */
		font-size: 45upx
	}
	.fs26{
		font-size:39upx
		/* font-size: 26upx */
	}
	.fs12{
		font-size: 18upx
		/* font-size: 12upx */
	}
	.fs16{
		font-size: 24upx
		/* font-size: 16upx */
	}
	.fs14{
		font-size: 21upx
		/* font-size: 14upx */
	}
	.fs15{
		font-size: 22.5upx
		/* font-size: 15upx */
	}
	.fs27{
		font-size: 40.5upx
		/* font-size: 27upx */
	}
	.fs18{
		font-size: 27upx
		/* font-size: 18upx */
	}
	.fs28{
		font-size: 42upx
		/* font-size: 28upx */
	}
	.fs10{
		font-size: 15upx
		/* font-size: 10upx */
	}
	.fs30{
		font-size: 45upx
		/* font-size: 28upx */
	}
	.fs36{
		font-size: 54upx
		/* font-size: 28upx */
	}
	
	.fs24{
		font-size: 36upx
		/* font-size: 24upx */
	}
	.fs20{
		font-size:30upx
		/* font-size: 20upx */
	}
	.fs22{
		font-size:33upx
		/* font-size: 22upx */
	}
	.fs21{
		font-size: 31.5upx
		/* font-size: 21upx */
	}	
	.flexsb{
		display: flex;
		justify-content: space-between;
	}
	.plr20{
		padding: 0 20upx;
	}
	.plr10{
		padding: 0 10upx;
	}
	.f6f4f5{
		background-color: #fff;
	}	
	.Cf74d0f{
		color: #f74d0f;
	}
	.C2dc34d{
		color: #2dc34d;
	}
	.mt20{
		margin-top: 20upx;
	}
	.ti2{
		text-indent: 2em;
	}
	
	
	.content{
		min-height: 100vh;
		background-color: #FFFFFF;
		padding-bottom: 200upx;
	}
	
	.bottom{
		box-sizing: border-box;
		padding: 0 10upx;
		background-color: #FFFFFF;
		position: fixed;
		z-index: 99999999999;
		left: 0;
		bottom: 0;
		height: 98upx;
		width: 100%;
		box-shadow: 0upx -1upx 10upx rgba(0,0,0,0.8);
		display: flex;
		flex-direction: row;
		justify-content: space-around;
	}
	.bottom view{
		font-size: 27upx;
		color: #666;
		text-align: center;
		margin-top: -4upx;
	}
	.bottom view.active2{
		color: #ff4300;
	}
	.bottom image{
		position: relative;
		top: 15upx;
		width: 48upx;
		height: 48upx;
	}
	.title{
		padding-left: 20upx;
		background-color: #fff;
		padding-top: 30upx;
		border-bottom: 1upx solid #f1f1f1;
	}
	.process{		
		padding: 30upx 80upx;
		background-color: #fff;
		box-sizing: border-box;
	}
	.circles{
		margin-top: 20upx;
		padding: 0 30upx;
		position: relative;
		z-index: 99;
	}
	.line{
		position: relative;
		z-index: 0;
		top: 40upx;
		width: 650upx;
		height: 2upx;
		margin: 0 auto;
	}
	.processTitle view.processActive{
		color: #ff4300;
	}
	.tousuContent{
		box-sizing: border-box;
		margin-top: 20upx;
		background-color: #fff;
	}
	.title2{
		padding-left: 20upx;
		height: 70upx;
		line-height: 90upx;
		padding-bottom: 15upx;
	}
	.commonLi{
		/* border-top: 1upx solid #AAAAAA; */
		padding: 20upx;
	}
	.commonLi image+image{
		margin-left: 33upx;
	}
	.flex0{
		display: flex;
	}
	.Cf71c6e{
		color: #ff4300;
	}
	.submitBtn{
		width: 600upx;
		height: 70upx;
		line-height: 70upx;
		text-align: center;
		color: #fff;
		background-color: #ff4300;
		margin: 50upx auto;
	}
</style>

